package br.ebula.apl.dao;

import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import br.ebula.apl.bean.Bula;
import br.ebula.apl.dto.DTOIncluiBula;

public class DAOIncluiBula extends DAOGenerico {

	DTOIncluiBula dto;
	
	public boolean verificaBulaNaoCadastrada(DTOIncluiBula dto) {

		this.dto = dto;
		ResultSet rs = executaProcedure("inclui_bula_validacao",4);

		try {
			if(rs.next()) {
				return false;
			}
			return true;
		} catch (SQLException e) {
			e.printStackTrace();
		}

		return false;
	}

	public void incluiBula(DTOIncluiBula dto) {
		this.dto = dto;
		executaProcedure("inclui_bula",4);
	}

	@Override
	void configuraParametros(CallableStatement cstmt) throws SQLException {
		Bula b = dto.getBula();
		cstmt.setString(1, b.getNome());
		cstmt.setString(2, b.getPrincipioAtivo());
		cstmt.setString(3, b.getClasse());
		cstmt.setString(4, b.getSintomas());
	}
	
}
